## Replication code for 'What Drives Unequal Policy Responsiveness? Assessing the Role of Informational Asymmetries in Economic Policy-Making'
##
library(tidyverse)
library(ggthemes)
df <-  read.csv("DK_final.csv", header = TRUE)
df.nomiss <-  dplyr::filter(df, pre_1 !="NA")
df.nomiss <- mutate(df.nomiss, pre_all=(pre_1+pre_10+pre_20+pre_30+pre_40+pre_50+pre_60+pre_70+pre_80+pre_90+pre_100)/11)

df.nomiss$scode.alt <- factor(df.nomiss$scode,
                              levels = c("Unemployment Benefits", "Social Assistance", "Active Labor Market Policies", "Housing Benefits",
                                         "Child Benefits", "Elderly Care",  "Health", 
                                         "Education", "Environment", "Culture", 
                                         "Research", "Child Care Institutions", "Defense", "Police",
                                         "Developmental Aid", "Public Administration", 
                                         "Highways & Bridges", "Public Transportation"),
                              labels = c("UB", "Social assistance", "ALMP", "Housing benefits",
                                         "Child benefits", "Elderly care",  "Health", 
                                         "Education", "Environment", "Culture", 
                                         "Research", "Child care ins.", "Defense", "Police",
                                         "Development aid", "Public admin.", 
                                         "Highw. & bridges", "Public transport."))


##### Figure 3
df.nomiss.sort <- mutate(df.nomiss,
                         scode.alt = reorder(scode.alt, -pre_all, mean))

df.text <- data.frame(
  label = c("H", "M", "L"),
  scode.alt   = c("Health", "Elderly care", "Education"),
  year     = c(2000,1987,2001),
  pre_100     = c(14,35,14)
)

df.arrows <- data.frame(scode.alt=c("Health","Elderly care", "Education"),
                        x=c(1998,1988,1999),
                        y=c(22,45,14),
                        xend=c(1994,1992.5,1993),
                        yend=c(44,67,21))

tsplot <- ggplot(data=df.nomiss.sort) +
  geom_hline(yintercept=0, color="darkgrey") +
  geom_line(mapping=aes(x=year, y=pre_99, linetype="High")) +
  geom_line(mapping=aes(x=year, y=pre_50, linetype="Medium")) +
  geom_line(mapping=aes(x=year, y=pre_1, linetype="Low")) +
  geom_rug(mapping = aes(x=year, pre_1), col="black", sides="b") +
  facet_wrap(~scode.alt, nrow = 3) + 
  scale_y_continuous(breaks = c(-60, -40, -20, 0, 20, 40, 60, 80), labels = c("","-40", "", "0", "", "40", "", "80")) +
  scale_x_continuous(breaks = c(1985,1990,1995,2000,2005,2010,2015), labels = c("","'90","","'00","","'10", "")) +
  scale_linetype_manual(values=c("Low"="dotted", "Medium"="dashed", "High"="solid")) +
  theme_few() +
  theme(strip.background = element_rect(colour="black", fill="white"), legend.position="none")  +
  labs(x = "Year", y="Net Support") + 
  geom_text(
  data    = df.text,
  mapping = aes(x = year, y = pre_100, label = label), size=3.5
) +
  geom_curve(data = df.arrows %>% filter(scode.alt=="Health"),
             aes(x=x,y=y,xend=xend,yend=yend),
             curvature = -0.1, linetype="solid", size=.2,
             arrow = arrow(type="open",length = unit(0.25,"cm"))) +
  geom_curve(data = df.arrows %>% filter(scode.alt=="Elderly care"),
             aes(x=x,y=y,xend=xend,yend=yend),
             curvature = -0.1,linetype="solid", size=.2,
             arrow = arrow(type="open",length = unit(0.25,"cm"))) +
  geom_curve(data = df.arrows %>% filter(scode.alt=="Education"),
             aes(x=x,y=y,xend=xend,yend=yend),
             curvature = -0.1, linetype="solid", size=.2,
             arrow = arrow(type="open",length = unit(0.25,"cm")))
tsplot

##### Figure 4
df.b1_b100  <-  read.csv("Regression_results_p1-p100.csv", header = TRUE)

b <- ggplot(data=df.b1_b100) +
  geom_smooth(mapping=aes(x=percentile, y=beta_min, linetype="CI"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=beta, linetype="Beta"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=beta_max, linetype="CI"), color="black", size=1, se=FALSE) +
  labs(title="Coefficient", x = "Income percentile", y="") +
  scale_y_continuous(limits = c(.00, .08)) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
b

a <- ggplot(data=df.b1_b100) +
  geom_smooth(mapping=aes(x=percentile, y=cons_min, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=cons, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=cons_max, linetype="solid"), color="black", size=1, se=FALSE) +
  scale_y_continuous(limits = c(0, 4.15)) +
  labs(title="Intercept", x = "Income percentile", y="") +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
a


r <- ggplot(data=df.b1_b100) +
  geom_smooth(mapping=aes(x=percentile, y=r2_lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=r2, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=r2_upper, linetype="solid"), color="black", size=1, se=FALSE) +
  #scale_y_continuous(limits = c(0, 4.15)) +
  labs(title="R-squared", x = "Income percentile", y="") +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
r


##### Figure 5
library(margins)
df.pol.know  <-  read.csv("political_information.csv", header = TRUE)

# fig 5a (No one)
noone <- glm(formula = disc_pol_no~ income+y_02+ y_05+ y_08+ y_11, family = binomial, data = df.pol.know)
summary(noone)
df.noone <- cplot(noone, "income", draw = FALSE)
df.noone.nomiss <- dplyr::filter(df.pol.know, disc_pol_no!="NA")

p.noone <- ggplot(data=df.noone) +
  geom_smooth(mapping=aes(x=xvals, y=lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=yvals, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=upper, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_rug(data=df.noone.nomiss, aes(x=income, disc_pol_no,alpha = 1),position = "jitter", col="black", size=.1, sides="b")+
  scale_y_continuous(breaks = c(0,.2,.4,.6,.8,1), limits = c(0, 1)) +
  labs(title="a) With no one", x = "Income percentile", y=expression("Predicted probability")) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=21.66667),
        axis.title=element_text(size=24.375),
        plot.title = element_text(size=29.79167, hjust=0.5))
p.noone

# fig 5b (Friends)
friends <- glm(formula = disc_pol_friends~ income+y_94+y_98+y_02+ y_05+ y_08+ y_11, family = binomial, data = df.pol.know)
summary(friends)
df.friends <- cplot(friends, "income", draw = FALSE)
df.friends.nomiss <- dplyr::filter(df.pol.know, disc_pol_friends!="NA")

p.friends <- ggplot(data=df.friends) +
  geom_smooth(mapping=aes(x=xvals, y=lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=yvals, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=upper, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_rug(data=df.friends.nomiss, aes(x=income, disc_pol_friends,alpha = 1),position = "jitter", col="black", size=.1, sides="b")+
  scale_y_continuous(breaks = c(0,.2,.4,.6,.8,1), limits = c(0, 1)) +
  labs(title="b) With friends", x = "Income percentile", y=expression("Predicted probability")) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=21.66667),
        axis.title=element_text(size=24.375),
        plot.title = element_text(size=29.79167, hjust=0.5))
p.friends

# fig 5c (Family)
family <- glm(formula = disc_pol_fam~ income+y_94+y_98+y_02+ y_05+ y_08+ y_11, family = binomial, data = df.pol.know)
summary(family)
df.family <- cplot(family, "income", draw = FALSE)
df.family.nomiss <- dplyr::filter(df.pol.know, disc_pol_fam!="NA")

p.family <- ggplot(data=df.family) +
  geom_smooth(mapping=aes(x=xvals, y=lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=yvals, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=upper, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_rug(data=df.family.nomiss, aes(x=income, disc_pol_fam,alpha = 1),position = "jitter", col="black", size=.1, sides="b")+
  scale_y_continuous(breaks = c(0,.2,.4,.6,.8,1), limits = c(0, 1)) +
  labs(title="c) With family", x = "Income percentile", y=expression("Predicted probability")) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=21.66667),
        axis.title=element_text(size=24.375),
        plot.title = element_text(size=29.79167, hjust=0.5))
p.family

# fig 5d (Colleagues)
colleagues <- glm(formula = disc_pol_col~ income+y_91+y_94+y_98+y_02+ y_05+ y_08+ y_11, family = binomial, data = df.pol.know)
summary(colleagues)
df.colleagues <- cplot(colleagues, "income", draw = FALSE)
df.colleagues.nomiss <- dplyr::filter(df.pol.know, disc_pol_col!="NA")

p.colleagues <- ggplot(data=df.colleagues) +
  geom_smooth(mapping=aes(x=xvals, y=lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=yvals, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=upper, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_rug(data=df.colleagues.nomiss, aes(x=income, disc_pol_col,alpha = 1),position = "jitter", col="black", size=.1, sides="b")+
  scale_y_continuous(breaks = c(0,.2,.4,.6,.8,1), limits = c(0, 1)) +
  labs(title="d) With colleagues", x = "Income percentile", y=expression("Predicted probability")) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=21.66667),
        axis.title=element_text(size=24.375),
        plot.title = element_text(size=29.79167, hjust=0.5))
p.colleagues


##### Figure 6
df.pol.know  <-  read.csv("political_information.csv", header = TRUE)

# fig 6a
mod.pol <- lm(sd_pol_knowledge~ I(income^2) + income+ y_08 + y_11 + y_15, data = df.pol.know)
summary(mod.pol)
df.pol <- cplot(mod.pol, "income", draw = FALSE)
mod.pol.nomiss <- dplyr::filter(df.pol.know, sd_pol_knowledge!="NA")

info.pol <- ggplot(data=df.pol) +
  geom_smooth(mapping=aes(x=xvals, y=lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=yvals, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=upper, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_rug(data=mod.pol.nomiss, aes(x=income, alpha = 1), col="black", size=.1, sides="b")+
  scale_y_continuous(breaks = c(-.4,-.2,0,.2,.4,.6), limits = c(-.4, .62)) +
  labs(title="a) Politics and the economy", x = "Income percentile", y=expression("Predicted level of information (standardized)")) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
info.pol

# fig 6b
mod.eco <- lm(sd_forsta_oko~ I(income^2) + income+ y_98 +y_02+ y_05+ y_08+ y_11+ y_15, data = df.pol.know)
summary(mod.eco)
df.eco <- cplot(mod.eco, "income", draw = FALSE)
mod.eco.nomiss <- dplyr::filter(df.pol.know, sd_forsta_oko!="NA")

eval.eco <- ggplot(data=df.eco) +
  geom_smooth(mapping=aes(x=xvals, y=lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=yvals, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=upper, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_rug(data=mod.eco.nomiss, aes(x=income, alpha = 1), col="black", size=.1, sides="b")+
  scale_y_continuous(breaks = c(-.4,-.2,0,.2,.4,.6), limits = c(-.4, .62)) +
  labs(title="b) Economic policy (subjective)",x = "Income percentile", y=expression("Predicted level of information (standardized)")) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
eval.eco


# fig 6c
df.eco.know  <-  read.csv("economic_information.csv", header = TRUE)

mod.eco.know <- lm(sd_eco_know~ I(income1^2) + income1, data = df.eco.know)
summary(mod.eco.know)
df.mod.eco.know <- cplot(mod.eco.know, "income1", draw = FALSE)
df.mod.eco.know.nomiss <- dplyr::filter(df.eco.know, sd_eco_know!="NA")

info.eco <- ggplot(data=df.mod.eco.know) +
  geom_smooth(mapping=aes(x=xvals, y=lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=yvals, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=xvals, y=upper, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_rug(data=df.mod.eco.know.nomiss, aes(x=income1, sd_eco_know,alpha = 1),position = "jitter", col="black", size=.1, sides="b")+
  scale_y_continuous(breaks = c(-.4,-.2,0,.2,.4,.6), limits = c(-.4, .62)) +
  labs(title="c) Economic issues", x = "Income percentile", y=expression("Predicted level of information (standardized)")) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
info.eco

################################
# Web Appendix A: Scatterplots
################################
# spending and preferences
df.full <-  read.csv("DK_final.csv", header = TRUE)
df.no.outlier <- dplyr::filter(df.full, v1!=1 & v1!=514 & v1!=537 & v1!=272 & v1!=255 & v1!=297 & v1!=266 & spend2!="NA" & pre_1!="NA")

# Figure A1.
p.L <- ggplot(aes(x=pre_1, y=spend2), data=df.no.outlier)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="Low income", x = "Net support", y="two-year changes in spending")+
  scale_x_continuous(limits = c(-70, 80)) +
  scale_y_continuous(limits = c(-12, 17)) +
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.L


p.M <- ggplot(aes(x=pre_50, y=spend2), data=df.no.outlier)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="Middle income", x = "Net support", y="two-year changes in spending")+
  scale_x_continuous(limits = c(-70, 80)) +
  scale_y_continuous(limits = c(-12, 17)) +
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.M


p.H <- ggplot(aes(x=pre_99, y=spend2), data=df.no.outlier)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="High income", x = "Net support", y="two-year changes in spending")+
  theme(legend.position="FALSE") + theme_few() +
  scale_x_continuous(limits = c(-70, 80)) +
  scale_y_continuous(limits = c(-12, 17)) +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.H


## Discussion of Politics ##
df.pol.know  <-  read.csv("political_information.csv", header = TRUE)

# Figure A2
# no one
p.noone <- ggplot(aes(x=income, y=disc_pol_no), data=df.pol.know)+
  geom_jitter(height = 0.05, color="black", size=4, alpha = .01)+
  geom_smooth(color="blue", size=4, se=FALSE, method="loess")+
  labs(title="With no one", x = "Income", y="Discussion of politics")+
  scale_y_continuous(breaks = c(0, .2, .4, .6, .8,1), limits = c(-.05, 1.05)) +
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.noone


# Friends
p.friends <- ggplot(aes(x=income, y=disc_pol_friends), data=df.pol.know)+
  geom_jitter(height = 0.05, color="black", size=4, alpha = .01)+
  geom_smooth(color="blue", size=4, se=FALSE, method="loess")+
  labs(title="With friends", x = "Income", y="Discussion of politics")+
  scale_y_continuous(breaks = c(0, .2, .4, .6, .8,1), limits = c(-.05, 1.05)) +
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.friends


# Family
p.family <- ggplot(aes(x=income, y=disc_pol_fam), data=df.pol.know)+
  geom_jitter(height = 0.05, color="black", size=4, alpha = .01)+
  geom_smooth(color="blue", size=4, se=FALSE, method="loess")+
  labs(title="With family", x = "Income", y="Discussion of politics")+
  scale_y_continuous(breaks = c(0, .2, .4, .6, .8,1), limits = c(-.05, 1.05)) +
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.family

# Colleagues
p.colleagues <- ggplot(aes(x=income, y=disc_pol_col), data=df.pol.know)+
  geom_jitter(height = 0.05, color="black", size=4, alpha = .01)+
  geom_smooth(color="blue", size=4, se=FALSE, method="loess")+
  labs(title="With colleagues", x = "Income", y="Discussion of politics")+
  scale_y_continuous(breaks = c(0, .2, .4, .6, .8,1), limits = c(-.05, 1.05)) +
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.colleagues

##########################################
### Political and Economic Information ###
##########################################

# Figure A3
# Self-evaluated knowledge of fiscal policy
p.subeco <- ggplot(aes(x=income, y=sd_forsta_oko), data=df.pol.know)+
  geom_jitter(height = 0.05, color="black", size=4, alpha = .1)+
  geom_smooth(color="blue", size=4, se=FALSE, method="loess")+
  labs(title="Economic policy (subjective)", x = "Income", y="Information (standardized)")+
  scale_y_continuous(breaks = c(-1.5,-1,-.5, 0,.5, 1, 1.5), limits = c(-1.75, 1.75)) +
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.subeco

# Political information
p.polinfo <- ggplot(aes(x=income, y=sd_pol_knowledge), data=df.pol.know)+
  geom_jitter(height = 0.00, color="black", size=4, alpha = .1)+
  geom_smooth(color="blue", size=4, se=FALSE, method="loess")+
  labs(title="Politics and the economy", x = "Income", y="Information (standardized)")+
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.polinfo


# Economic information
df.eco.know  <-  read.csv("economic_information.csv", header = TRUE)
p.ecoinfo <- ggplot(aes(x=income1, y=sd_eco_know), data=df.eco.know)+
  geom_jitter(height = 0.05, color="black", size=4, alpha = .1)+
  geom_smooth(color="blue", size=4, se=FALSE, method="loess")+
  labs(title="Economic issues", x = "Income", y="Information (standardized)")+
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.ecoinfo


###### 
# Responses of preferences to state of the economy
######
# Figure A4
df.change  <-  read.csv("change.csv", header = TRUE)
df.c <-  dplyr::filter(df.change,  changeyear<5)

p.umemp_L <- ggplot(aes(x=changeunemp, y=changepre_1), data=df.c)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="Low income", x = "Changes in unemployment", y="Changes in net support")+
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.umemp_L

p.umemp_M <- ggplot(aes(x=changeunemp, y=changepre_50), data=df.c)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="Middle income", x = "Changes in unemployment", y="Changes in net support")+
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.umemp_M


p.umemp_H <- ggplot(aes(x=changeunemp, y=changepre_99), data=df.c)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="High income", x = "Changes in unemployment", y="Changes in net support")+
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.umemp_H

# Figure A5
####### Change in spending
p.spend_L <- ggplot(aes(x=changespend_levels_std, y=changepre_1), data=df.c)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="Low income", x = "Changes in spending", y="Changes in net support")+
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.spend_L

p.spend_M <- ggplot(aes(x=changespend_levels_std, y=changepre_50), data=df.c)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="Middle income", x = "Changes in spending", y="Changes in net support")+
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.spend_M


p.spend_H <- ggplot(aes(x=changespend_levels_std, y=changepre_99), data=df.c)+
  geom_point(color="black", size=4, alpha = .3)+
  geom_smooth(color="red", size=2, se=FALSE, method="lm")+
  geom_smooth(color="blue", size=2, se=FALSE, method="loess", span=1.25)+
  labs(title="High income", x = "Changes in spending", y="Changes in net support")+
  theme(legend.position="FALSE") + theme_few() +
  theme(axis.text=element_text(size=18),
        axis.title=element_text(size=20),
        plot.title = element_text(size=26, face="bold", hjust=0.5),
        plot.subtitle = element_text(size=26, face="bold", hjust=0.5),
        aspect.ratio = 1)
p.spend_H


################################
# Web Appendix B: Outliers
################################
df.full <-  read.csv("DK_final.csv", header = TRUE)

mod.1 <- lm(spend2~pre_1, data=df.full)
mod.50 <- lm(spend2~pre_50, data=df.full)
mod.99 <- lm(spend2~pre_99, data=df.full)
mod.1_99 <- lm(spend2~pre_1+pre_50+pre_99, data=df.full)

avPlots(mod.1,~pre_1,
        xlab="Net preferences | X", ylab="Changes in spending | X",
        cex=1.5, cex.lab=1.5, cex.axis=1.5,
        col.lines="black",
        id.method = list(abs(residuals(mod.1, type="pearson")), "y"),
        id.n=7, 
        id.cex=1.5,
        id.col="black")
title("a) Low income", cex.main=2.0, font.main=1)

avPlots(mod.50,~pre_50,
        xlab="Net Preferences | X",
        ylab="Changes in Spending | X",
        cex=1.5, cex.lab=1.5, cex.axis=1.5,
        col.lines="black",
        id.method = list(abs(residuals(mod.50, type="pearson")), "y"),
        id.n=7, 
        id.cex=1.5,
        id.col="black")
title("b) Middle income", cex.main=2.0, font.main=1)

avPlots(mod.99,~pre_99,
        main="",
        xlab="Net Preferences | X",
        ylab="Changes in Spending | X",
        cex=1.5, cex.lab=1.5, cex.axis=1.5,
        col.lines="black",
        id.method = list(abs(residuals(mod.99, type="pearson")), "y"),
        id.n=7, 
        id.cex=1.5,
        id.col="black")
title("c) High income", cex.main=2.0, font.main=1)

avPlots(mod.1_99,~pre_1,
        main="",
        xlab="Net Preferences | X",
        ylab="Changes in Spending | X",
        cex=1.5, cex.lab=1.5, cex.axis=1.5,
        col.lines="black",
        id.method = list(abs(residuals(mod.1_99, type="pearson")), "y"),
        id.n=7, 
        id.cex=1.5,
        id.col="black")
title("a) Low income", cex.main=2.0, font.main=1)

avPlots(mod.1_99,~pre_50,
        main="",
        xlab="Net Preferences | X",
        ylab="Changes in Spending | X",
        cex=1.5, cex.lab=1.5, cex.axis=1.5,
        col.lines="black",
        id.method = list(abs(residuals(mod.1_99, type="pearson")), "y"),
        id.n=7, 
        id.cex=1.5,
        id.col="black")
title("b) Middle income", cex.main=2.0, font.main=1)

avPlots(mod.1_99,~pre_99,
        main="",
        xlab="Net Preferences | X",
        ylab="Changes in Spending | X",
        cex=1.5, cex.lab=1.5, cex.axis=1.5,
        col.lines="black",
        id.method = list(abs(residuals(mod.1_99, type="pearson")), "y"),
        id.n=7, 
        id.cex=1.5,
        id.col="black")
title("c) High income", cex.main=2.0, font.main=1)



#################################################################################
# Web Appendix C: The Empirical Distribution of Political Representation - Voters
#################################################################################
df.b1_b100  <-  read.csv("Regression_results_p1-p100_voters.csv", header = TRUE)

b.voters <- ggplot(data=df.b1_b100) +
  geom_smooth(mapping=aes(x=percentile, y=beta_min, linetype="CI"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=beta, linetype="Beta"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=beta_max, linetype="CI"), color="black", size=1, se=FALSE) +
  labs(title="Coefficient", x = "Income percentile", y="") +
  scale_y_continuous(limits = c(.00, .08)) +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
b.voters

a.voters <- ggplot(data=df.b1_b100) +
  geom_smooth(mapping=aes(x=percentile, y=cons_min, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=cons, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=cons_max, linetype="solid"), color="black", size=1, se=FALSE) +
  scale_y_continuous(limits = c(0, 5)) +
  labs(title="Intercept", x = "Income percentile", y="") +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
a.voters

r.voters <- ggplot(data=df.b1_b100) +
  geom_smooth(mapping=aes(x=percentile, y=r2_lower, linetype="solid"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=r2, linetype="dash"), color="black", size=1, se=FALSE) +
  geom_smooth(mapping=aes(x=percentile, y=r2_upper, linetype="solid"), color="black", size=1, se=FALSE) +
  #scale_y_continuous(limits = c(0, 4.15)) +
  labs(title="R-squared", x = "Income percentile", y="") +
  theme_bw() + theme(legend.position="FALSE") +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=18),
        plot.title = element_text(size=22, hjust=0.5))
r.voters

